<?php 
session_cache_expire(999999999);
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<?php
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../../value/value_en.php";
} else if($lang == "VN") {
	include "../../value/value_vn.php";
}
else {
	include "../../value/value_kr.php";
}
include '../../content-accountant/invoicetax.php';
include '../../generallibraries/funcs.php';
$tongtieninput=0;
$tongcong=0;

if(isset($_REQUEST['type']) && isset($_REQUEST['value']) && isset($_REQUEST['vitri'])){
	$type=$_REQUEST['type'];
	$vitri=$_REQUEST['vitri'];
	$value=rawurldecode($_REQUEST['value']);
	if($type=="txtday"){
		$inobject= unserialize (serialize ($_SESSION['input_invoice'][$vitri]));
		$inobject->orday=$value;
		$_SESSION['input_invoice'][$vitri]=$inobject;
	}else if($type=="txtcusname"){
		$inobject= unserialize (serialize ($_SESSION['input_invoice'][$vitri]));
		$inobject->cusname=$value;
		$_SESSION['input_invoice'][$vitri]=$inobject;
	}else if($type=="txtquantity"){
		$inobject= unserialize (serialize ($_SESSION['input_invoice'][$vitri]));
		$inobject->order_quantity=generalFunctions::numberformat_to_basicString($value);
		$inobject->tinhthue();
		$inobject->tinhtien();
		$_SESSION['input_invoice'][$vitri]=$inobject;
	}else if($type=="txtrice"){
		$inobject= unserialize (serialize ($_SESSION['input_invoice'][$vitri]));
		$inobject->order_suplly_rice=generalFunctions::numberformat_to_basicString($value);
		$inobject->tinhthue();
		$inobject->tinhtien();
		$_SESSION['input_invoice'][$vitri]=$inobject;
	}else if($type=='txtitem'){
		$inobject= unserialize (serialize ($_SESSION['input_invoice'][$vitri]));
		$inobject->order_content=$value;
		$_SESSION['input_invoice'][$vitri]=$inobject;
	}else if($type=="txttimetran"){
		$inobject= unserialize (serialize ($_SESSION['input_invoice'][$vitri]));
		$inobject->order_time_transaction=$value;
		$_SESSION['input_invoice'][$vitri]=$inobject;
	}
}

?>
<body>	
<table cellpadding="0" cellspacing="1" width="100%" border="0" class="ftable">
            <tr >
            	<th></th>
                <th><?=$l_no?>.</th>
                <th><?=$l_month?></th>
                <th><?=$l_days?></th>
                <th><?=$l_customer?></th>
                <th><?=$l_product_item?></th>
                <th><?=$l_quantity?></th>
                <th><?=$l_Supply_price?></th>
                <th><?=$l_vat?></th>
                <th><?=$l_amount?></th>
                <th><?=$l_thoigiangiaodich?></th>
            </tr>
            <?php 
	        if(isset($_SESSION['input_invoice']) && count($_SESSION['input_invoice'])>0){
	            	for($i=0;$i<count($_SESSION['input_invoice']);$i++){
	            		$inobject= unserialize (serialize ($_SESSION['input_invoice'][$i]));
            			?>
            			<tr >
            			<td><img onclick="deleteclick(<?=$i?>)" src="images/del.png" style="width:20px;height:20px;cursor:pointer;" title="<?php echo $l_delete;?>" /></td>
	            		<td><?=($i+1)?></td>
		                <td><?=$inobject->ormonth?></td>
		                <td>
		                	<input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']);?>,'1')" onchange="chDay(this.value,<?=$i?>,'day');" onkeyup="chDay(this.value,<?=$i?>,'day');" id="<?echo "txtday".$i?>" name="vday[]" style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;"	value="<?=$inobject->orday?>" autocomplete="off"  />
		                </td>
		                <td>
		                	<input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']);?>,'0')" onchange="chDay(this.value,<?=$i?>,'usname');" onkeyup="chDay(this.value,<?=$i?>,'cusname');" id="<?echo "txtcusname".$i?>" name="vcusname[]" style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;"	value="<?= $inobject->cusname?>" autocomplete="off"  />
		                </td>
		                <td>
		                	<input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']);?>,'0')" onchange="chDay(this.value,<?=$i?>,'item');" onkeyup="chDay(this.value,<?=$i?>,'item');" id="<?echo "txtitem".$i?>" name="vitem[]" style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;"	value="<?=$inobject->order_content?>" autocomplete="off"  />
		                </td>
		                <td>
		                	<input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']);?>,'1')" onchange="chDay(this.value,<?=$i?>,'quantity');" onkeyup="chDay(this.value,<?=$i?>,'quantity');" id="<?echo "txtquantity".$i?>" name="vquantity[]" style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;"	value="<?=$inobject->order_quantity?>" autocomplete="off"  />
		                </td>
		                <td>
		                	<input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']);?>,'1')" onchange="chDay(this.value,<?=$i?>,'rice');" onkeyup="chDay(this.value,<?=$i?>,'rice');" id="<?echo "txtrice".$i?>" name="vrice[]" style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;"	value="<?=$inobject->order_suplly_rice?>" autocomplete="off"  />
		                </td>
		                <td><?=number_format($inobject->order_tax)?></td>
		                <td><?=number_format($inobject->order_total)?></td>
		                <td>
		                	<input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']);?>,'0')" onchange="chDay(this.value,<?=$i?>,'timetran');" onkeyup="chDay(this.value,<?=$i?>,'timetran');" id="<?echo "txttimetran".$i?>" name="vtimetran[]" style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;text-align:center;"	value="<?=$inobject->order_time_transaction?>" autocomplete="off"  />
		                </td>
	            		</tr>
	            		<?php 
	            		$tongtieninput +=$inobject->order_total;
	            		$tongcong +=$inobject->order_total;
            		}
            }else{
            ?>
            <tr><td colspan="11" style="height:30px;text-align:left;padding-left:20px;"><?php echo $l_list_emplty;?></td></tr>
            <?php }?>
            <tr class="coltr2" style="height:30px;">
                <td colspan="5"></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td><?php echo number_format($tongtieninput);?></td>
                <td></td>
            </tr>            
        </table>       
    	<input type="hidden" value="<?=count($_SESSION['input_invoice'])?>" id="soluongphantu" />
</body>
</html>
